import request from './request'

/**
 * 发送通知
 */
export const sendNotification = (data) => {
  return request({
    url: '/notification/send',
    method: 'post',
    data
  })
}

/**
 * 分页查询我的通知
 */
export const getMyNotifications = (data) => {
  return request({
    url: '/notification/my/list',
    method: 'post',
    data
  })
}

/**
 * 获取通知详情
 */
export const getNotificationDetail = (id) => {
  return request({
    url: `/notification/${id}`,
    method: 'get'
  })
}

/**
 * 标记通知为已读
 */
export const markAsRead = (receiverId) => {
  return request({
    url: `/notification/read/${receiverId}`,
    method: 'put'
  })
}

/**
 * 标记所有通知为已读
 */
export const markAllAsRead = () => {
  return request({
    url: '/notification/read/all',
    method: 'put'
  })
}

/**
 * 删除通知
 */
export const deleteNotification = (receiverId) => {
  return request({
    url: `/notification/${receiverId}`,
    method: 'delete'
  })
}

/**
 * 获取未读通知数量
 */
export const getUnreadCount = () => {
  return request({
    url: '/notification/unread/count',
    method: 'get'
  })
}

/**
 * 撤回通知
 */
export const recallNotification = (notificationId) => {
  return request({
    url: `/notification/recall/${notificationId}`,
    method: 'put'
  })
}

